//
//  SYBaseTarBarViewController.swift
//  SheYangBigData
//
//  Created by 叁拾叁 on 2020/8/21.
//  Copyright © 2020 叁拾叁. All rights reserved.
//

import UIKit

class SYBaseTarBarViewController: UITabBarController {
    
    var roleId: String?

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.navigationController?.navigationBar.isHidden = true
    }
    
    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        self.navigationController?.navigationBar.isHidden = false
    }
    
    init(roleId: String?) {
        super.init(nibName: nil, bundle: nil)
        self.roleId = roleId
        
//        let homeVC = SYHomePageViewController()
//        let renyangVC = RYyunweiListViewController(hasTab: true)
//        let nongyouquanVC = PYQListViewController(hasTab: true)
//        let daoyouVC = DYDaoLanViewController(hasTab: true)
//
//        let myVC = SYMyViewController()
//        let gongzuotaiVC = SYGongzuotaiViewController()
//        NIMSDK.shared().conversationManager.add(self)
        let messageVC = MessageViewController()
        let workBenchVC = WorkBenchViewController()
        let myVC = MyViewController()
        
        
        
        
        
        addChildVC(childVC: messageVC, title: "消息", image: "message_icon")
//        if let id = roleId, id != "null", id == "2" || id == "4" {
//            addChildVC(childVC: gongzuotaiVC, title: "工作台", image: "gongzuotai")
//        } else {
//            addChildVC(childVC: renyangVC, title: "认养农业", image: "tab_renyang")
//            addChildVC(childVC: nongyouquanVC, title: "农友圈", image: "tab_nongyouquan")
//            addChildVC(childVC: daoyouVC, title: "导游导览", image: "tab_daoyou")
//        }
        addChildVC(childVC:workBenchVC , title: "工作台", image: "work_icon")
        addChildVC(childVC: myVC, title: "我的", image: "me_icon")
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = .white
        
    }
    
    func addChildVC(childVC:UIViewController,title:String,image:String) -> Void {
        childVC.title = title
        
        var img = UIImage(named: image)
        img = img?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal)
        
        var selectedImg = UIImage(named: image + "_select")
        selectedImg = selectedImg?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal)
        
        childVC.tabBarItem.image = img
        childVC.tabBarItem.selectedImage = selectedImg
        let nav = SYBaseNavigationController(rootViewController: childVC)
        addChild(nav)
    }

}

//extension SYBaseTarBarViewController: NIMConversationManagerDelegate {
//
//}
